import subprocess
def pullpictopath(picnum,path):
    cmd = 'adb shell "cd storage/emulated/0/DCIM/Camera; ls -t"'
    p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
    p.wait()
    res = p.stdout.read()
    print('[Info]','图片列表:')
    print(res,'\n')
    piclist = res.split('\n')
    cmd2 = ''
    # cmd2=[]
    if picnum >= len(piclist):
        cmd2 = 'adb pull storage/emulated/0/DCIM/Camera {};'.format(path)
    else:
        for i in range(picnum):
            cmd2 = cmd2 + 'adb pull storage/emulated/0/DCIM/Camera/{} {};'.format(piclist[i],path)
    p = subprocess.Popen(cmd2[:-1], stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
    p.wait()
    print(p.stdout.read())